package com.etnet.streamserver.view.client;

public class NssSenderManager {
    public static final String LEN_NONE = "-1";
    public static final String REQUEST_REQID_HEARTBEAT = "0";
    public static final String REQUEST_REQID_QUOTE = "1";
    public static final String REQUEST_REQID_SORT_INDUSTRY = "2";
    public static final String REQUEST_REQID_SORT_INDEX = "3";
    public static final String REQUEST_REQID_SORT_WAR = "4";
    public static final String REQUEST_REQID_SORT_CBBC = "5";
    public static final String REQUEST_REQID_SORT_STOCK = "6";
    public static final String REQUEST_REQID_BROKER_SEARCH = "7";
    public static final String REQUEST_REQID_LOGIN = "8";
    public static final String REQUEST_REQID_NEWS = "9";
    public static final String REQUEST_REQID_SYSTEM_MESSAGE = "10";
    public static final String REQUEST_REQID_MTS_MESSAGE = "11";
    public static final String REQUEST_REQID_BROKER_SEARCH_HV = "12";
    public static final String LINE_TAIL = "\n";
    public static final String LOGIN_SUCESS = "0";
    public static final String LOGIN_FAIL = "1";
    public static final String LOGIN_DUPLICATE = "2";
    public static final String MSG_SUCESS = "0";
    public static final String MSG_FAIL = "1";
    public static final String COMMAND_ADD_BROADCAST = "0";
    public static final String COMMAND_ADD_SNAPSHOT = "1";
    public static final String COMMAND_ADD_BOTH = "2";
    public static final String COMMAND_REMOVE = "3";
    public static String seqNo = "-1";

    public static String sendLoginStr(String token) {
        StringBuilder sb = new StringBuilder();
        getHeaderStr(sb, "-1", "8", seqNo);
        append(sb, "1");
        append(sb, token);
        sb.append("\n");
        return sb.toString();
    }

    private static void getHeaderStr(StringBuilder sb, String len, String reqID, String seqNo) {
        sb.append(len);
        append(sb, reqID);
        append(sb, seqNo);
    }

    private static void append(StringBuilder sb, String s) {
        if (s == null)
            s = "";
        sb.append(",");
        sb.append(s);
    }

    public static String sendMsgStr(String reqid, String reqActionType, String[] data) {
        StringBuilder sb = new StringBuilder();
        getHeaderStr(sb, "-1", reqid, seqNo);
        append(sb, reqActionType);
        if ((data != null) && (data.length > 0)) {
            for (String string : data) {
                append(sb, string);
            }
        }
        sb.append("\n");
        return sb.toString();
    }
}